from flask import Flask
from flask_sqlalchemy import SQLAlchemy
# 3.创建db对象
from flask_migrate import Migrate
from flask_cors import CORS

db = SQLAlchemy()


# 4.创建 app对象
def get_app(config):
    app = Flask(__name__)
    # 6.初始化配置文件
    app.config.from_object(config)
    db.init_app(app)  # 5.db绑定app
    #
    from oasys.user.views import bp
    app.register_blueprint(bp)
    # 创建Migrate对象
    Migrate(app, db)
    # 创建cors对象
    CORS(app, resources={r'/*': {'origins': '*'}})
    return app
